package cn.yunhe.service;

import cn.yunhe.dao.IAdminDao;
import cn.yunhe.entity.Admin;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

public class AddAdminService {
    SqlSession session= null;
    IAdminDao iAdminDao=null;

    public int addAdmin(String name,String pass){
        int flag=0;
        Admin admin=new Admin();
        admin.setName(name);
        admin.setPass(pass);
        try {
            session= SqlSessionFactoryUtil.getSqlSession();
            iAdminDao=session.getMapper(IAdminDao.class);
            flag=iAdminDao.addAdmin(admin);
            session.commit();
        }finally {
            session.close();
        }
        return flag;
    }

}
